﻿Imports System.Reflection

''' <summary>
''' Représente le gestionnaire de OMANE
''' </summary>
''' <remarks>
''' 
''' </remarks>
Public Class Application

    ''' <summary>
    ''' 
    ''' </summary>
    ''' <remarks></remarks>
    Protected Sub New()

    End Sub

    ''' <summary>
    ''' Méthode permettant de récupérer un service
    ''' </summary>
    ''' <remarks>
    ''' 
    ''' </remarks>
    Public Overridable Overloads Function GetService(Of T)() As T
        Return CType(GetService(GetType(T)), T)
    End Function

    ''' <summary>
    ''' Méthode permettant de récupérer un service
    ''' </summary>
    ''' <remarks>
    ''' 
    ''' </remarks>
    Public Overridable Overloads Function GetService(ByVal Name As String) As Object
        Throw New NotImplementedException()
    End Function

    ''' <summary>
    ''' Méthode permettant de récupérer un service
    ''' </summary>
    ''' <remarks>
    ''' 
    ''' </remarks>
    Public Overridable Overloads Function GetService(ByVal serviceType As System.Type) As Object
        Throw New NotImplementedException()
    End Function

    ''' <summary>
    ''' 
    ''' </summary>
    ''' <remarks></remarks>
    Public Overridable Sub NotifyChange(ByVal sender As Object, ByVal args As ChangeNotificationEventArgs)
        Dim final As ChangeNotificationEventArgs = args
        If final Is Nothing Then
            final = New ChangeNotificationEventArgs("OMANE.UnknownEvent")
        End If
        final.Push("_internal_Raising_Time_", DateTime.Now)
        If sender IsNot Nothing Then
            final.Push("_internal_Raising_Object_", sender.GetType().FullName)
        End If
        RaiseEvent ChangeEvent(sender, final)
    End Sub

    Public Overridable ReadOnly Property LoadedModules As IEnumerable(Of Type)
        Get
            Throw New NotImplementedException()
        End Get
    End Property

    Public Overridable Sub StartAsyncOperation(ByVal Operation As AsynchronousOperationHandler, ByVal info As AsynchronousOperationInfo)
        Throw New NotImplementedException()
    End Sub


    Public Event ChangeEvent As EventHandler(Of ChangeNotificationEventArgs)
End Class

Public Class AsynchronousOperationInfo
    Implements ComponentModel.INotifyPropertyChanged
    Implements IDisposable

    Public Property Data() As Object
    Public Property CanReportProgres As Boolean
    Public Property ShowUI As Boolean
    Private _progress As Double
    Public Property Progress As Double
        Get
            Return _progress
        End Get
        Set(ByVal value As Double)
            If _progress <> value Then
                If CanReportProgres Then
                    _progress = value
                    RaiseEvent PropertyChanged(Me, New ComponentModel.PropertyChangedEventArgs("Progress"))
                End If
            End If
        End Set
    End Property
    Public Property CompletedHandler As Action(Of AsynchronousOperationInfo)
    Private _message As String
    Public Property Message As String
        Get
            Return _message
        End Get
        Set(ByVal value As String)
            _message = value
            RaiseEvent PropertyChanged(Me, New ComponentModel.PropertyChangedEventArgs("Message"))
        End Set
    End Property

    Public Event PropertyChanged(ByVal sender As Object, ByVal e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged

#Region "IDisposable Support"
    Private disposedValue As Boolean ' Pour détecter les appels redondants

    ' IDisposable
    Protected Overridable Sub Dispose(ByVal disposing As Boolean)
        If Not Me.disposedValue Then
            If disposing Then
                ' TODO: supprimez l'état managé (objets managés).
            End If

            ' TODO: libérez les ressources non managées (objets non managés) et substituez la méthode Finalize() ci-dessous.
            ' TODO: définissez les champs volumineux à null.
        End If
        Me.disposedValue = True
    End Sub

    ' TODO: substituez Finalize() uniquement si Dispose(ByVal disposing As Boolean) ci-dessus comporte du code permettant de libérer des ressources non managées.
    'Protected Overrides Sub Finalize()
    '    ' Ne modifiez pas ce code. Ajoutez du code de nettoyage dans Dispose(ByVal disposing As Boolean) ci-dessus.
    '    Dispose(False)
    '    MyBase.Finalize()
    'End Sub

    ' Ce code a été ajouté par Visual Basic pour permettre l'implémentation correcte du modèle pouvant être supprimé.
    Public Sub Dispose() Implements IDisposable.Dispose
        ' Ne modifiez pas ce code. Ajoutez du code de nettoyage dans Dispose(ByVal disposing As Boolean) ci-dessus.
        Dispose(True)
        GC.SuppressFinalize(Me)
    End Sub
#End Region

End Class
Public Delegate Sub AsynchronousOperationHandler(ByVal [Module] As Type, ByVal Data() As Object)